﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace The_LarX
{
    public class Trigger : Component, ITrigger
    {
        public Actor Actor;

        public bool Inside { get; set; }

        public Renderer Renderer;

        public Trigger(Renderer renderer, GameScreen Screen)
            : base(Screen)
        {
            Actor = new Actor("Engine\\Models\\model_Cube");

            Actor.ComponentParent = this;
            Actor.Visible = false;
            this.Renderer = renderer;
            EngineSystem.Triggers.Add(this);
        }
        public Trigger()
        {
            Actor = new Actor("Engine\\Models\\model_Cube");/// CHANGE TO MODEL_SPHERE !!!
            Actor.ComponentParent = this;
            Actor.Visible = false;
            EngineSystem.Triggers.Add(this);
        }

        public override void Update()
        {
            base.Update();

            Actor.Update();
        }
        public override void Draw()
        {
            base.Draw();

            Actor.Draw();
        }

        public override void SerializeData()
        {
            base.SerializeData();

            Actor.SerializeData(Data);
            Data.AddData("Renderer.Name", this.Renderer.Name);
        }
        public override void DeserializeData()
        {
            base.DeserializeData();

            Actor = new Actor();
            Actor.DeserializeData(Data);

            Actor.ComponentParent = this;
            Renderer = EngineSystem.Renderers[Data.GetData<string>("Renderer.Name")];    
        }

        public virtual bool CheckIntersection(Vector3 Position)
        {
            return false;
        }

        public bool IfOutsideSetOff { get; set; }
    }
}
